package com.example.knowleage;

/**
 * @ClassName Test
 * @Description TODO
 * @Author KunxianLi
 * Date 2021/5/9 15:29
 * Version 1.0
 **/
public class Test {

    public static int tableSizeFor(int cap) {
        int n = cap - 1;
        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        return  n + 1;
    }

    public static void main(String[] args) {
        System.out.println(tableSizeFor(16));
    }
}
